<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="org.springside.modules.security.domain">
    <class name="Role" table="system_roles" dynamic-insert="true" dynamic-update="true">
		<id name="id" type="integer">
			<column name="id" />
            <generator class="native" >
				<param name="sequence">SYSTEM_ROLES_ID_SEQ</param>
            </generator>
		</id>
		<property name="name" type="string">
			<column name="name" length="50" not-null="true" />
		</property>
		<many-to-one name="dept" class="org.springside.modules.security.domain.Dept" fetch="select" insert="true" update="true">
			<column name="dept_id" not-null="false" />
		</many-to-one>
		<property name="descn" type="string">
			<column name="descn" />
		</property>
		<property name="state"  type="integer">
		   <column name="state" default="0" />
		</property>
		
		<!-- 用于分权时管理单元变更的状态 -->
		<property name="cuEnabled"  type="integer">
		   <column name="cu_enabled" default="1" />
		</property>
		
        <set name="users" order-by="role_id" table="system_user_role" lazy="true" inverse="false" cascade="save-update" batch-size="5">
            <key>
                <column name="role_id" not-null="true"/>
            </key>
            <many-to-many class="User" column="user_id" outer-join="auto"/>
        </set>
        <set name="permissions" table="system_role_perm" lazy="true" inverse="false" cascade="save-update" batch-size="5">
            <key>
                <column name="role_id" not-null="true"/>
            </key>
            <many-to-many class="Permission" column="perm_id"/>
        </set>
        <set name="menus" table="system_role_menu" lazy="true" inverse="false" cascade="save-update" batch-size="5">
            <key>
                <column name="role_id" not-null="true"/>
            </key>
            <many-to-many class="Menu" column="menu_id"/>
        </set>
        
    </class>
</hibernate-mapping>
